// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

//  基础样式文件的引入应放在App前面，否则build后template里面的css会被覆盖

import Vue from 'vue'
import App from './App'
import '@/assets/css/global.css';
import '@/assets/skin/skin_1/skinOne.css';
import '@/assets/skin/skin_2/skinTwo.css';
import '@/commons/globalRegister'
import router from './router/routes'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

window.vue.$message = ElementUI.Message;

Vue.use(ElementUI);
Vue.config.silent = true
Vue.config.productionTip = false;

router.beforeEach((to, from, next) => {
    let { title, requireAuth } = to.meta;
    if(requireAuth && !sessionStorage.getItem('token')) {
      window.vue.$message.warning('请先登录');
      next({
        name: 'login'
      });

      return;
    }

    let _title = ` - ${title}` || '';
    document.title = `数据检测${_title}`;

    next();
})

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
